When FT_Render_Glpyh fails the slot returns a bitmap containing a valid
width and height but a null buffer.
When we eventually memcpy this buffer we will crash. Existing error
handling in this method returns null on errors.
Pick-to: 6.10 6.8
Fixes: QTBUG-145310
Change-Id: I4737ab4d769b52f42bd1ef9037c8b9fd681a4ae8
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
(cherry picked from commit
1b4f4b1797bc7db3eea6ef83a34df61d7bf78e17)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Gbp-Pq: Name upstream_freetype-handle-failing-glyph-rendering.patch
FT_Library_SetLcdFilter(slot->library, (FT_LcdFilter)lcdFilterType);
err = FT_Render_Glyph(slot, renderMode);
- if (err != FT_Err_Ok)
- qWarning("render glyph failed err=%x face=%p, glyph=%d", err, face, glyph);
-
FT_Library_SetLcdFilter(slot->library, FT_LCD_FILTER_NONE);
+ if (err != FT_Err_Ok) {
+ qWarning("render glyph failed err=%x face=%p, glyph=%d", err, face, glyph);
+ return nullptr;
+ }
+
info.height = slot->bitmap.rows;
info.width = slot->bitmap.width;
info.x = slot->bitmap_left;